﻿@{
    Layout = null;
}

@model List<Ec_System.Models.Web.CustomerAdressData>

<script type="text/javascript" >

    $(document).ready(function () {
        getProvince();
       
        $("#ddlProvince").change(function () { getCity(); });
        $("#ddlRegion").change(function () { getTown(); });
    });

    function getProvince() {
        $("#ddlProvince").empty();
        $("#ddlRegion").empty();
        $("#ddlCounty").empty();
        $.getJSON("/Common/GetProvice", function (data) {
            $.each(data, function (i, item) {
                $("<option></option>").val(item["Area_ID"]).html(item["Area_Name"]).appendTo("#ddlProvince");
            });
        });
    }

    function getCity() {
        $("#ddlRegion").empty();
        $("#ddlCounty").empty();
        var url = "/Common/GetCity/" + $("#ddlProvince").val();
        console.log(url);
        $.getJSON(url, function (data) {
            $.each(data, function (i, item) {
                $("<option></option>").val(item["Area_ID"]).html(item["Area_Name"]).appendTo("#ddlRegion");
            });
        });
    }

    function getTown() {
        $("#ddlCounty").empty();
        var url = "/Common/GetTown/" + $("#ddlRegion").val();
        $.getJSON(url, function (data) {
            $.each(data, function (i, item) {
                $("<option></option>").val(item["Area_ID"]).html(item["Area_Name"]).appendTo("#ddlCounty");
            });
        });
    }
</script>

<script type="text/javascript">
    $().ready(function () {
        $("#userAddress").validate({
            rules: {
                txt_recever: { required: true },
                ddlProvince: { required: true },
                ddlRegion: { required: true },
                ddlCounty: { required: true },
                txt_zip: { required: true, rangelength: [6, 6] },
                txt_tel: { required: true, rangelength: [9, 11] },
                txt_addressMain: { required: true }
            },
            messages: {
                txt_recever: { required: "不能为空" },
                ddlProvince: { required: "不能为空" },
                ddlRegion: { required: "不能为空" },
                ddlCounty: { required: "不能为空" },
                txt_zip: { required: "不能为空", rangelength: "邮政编码长度为6" },
                txt_tel: { required: "不能为空", rangelength: "手机号码长度为9-11" },
                txt_addressMain: { required: "不能为空" }
            }
        });
    });
</script>

<div class="AreaR2">
    <div class="box">
        <div class="box_1">
            <div class="userCenterBox boxCenterList clearfix" style="_height:1%;">
                <h5><span>收货地址</span></h5>
                <div class="blank"></div>
                <div style="padding-left:10px">
                    @foreach (var item in Model)
                    {
                        <input type="radio" name="rdo_Adr" value="" @item.IsMainAddress  /><span style="color:black">@item.FullAddress</span>
                        <div>收 货 人：<span>@item.Recever</span></div>
                        <div>手机号码：<span>@item.TelNum</span></div>
                    }
                </div>
                @using (Html.BeginForm("AddCustomerAddress", "UserCenter", FormMethod.Post, new { name = "userAddress", id = "userAddress" }))
                {
                    @Html.AntiForgeryToken()
                    <div class="blank"></div>
                    <table width="100%" border="0" cellpadding="5" cellspacing="1">

                        <tr>
                            <td width="100" align="right" bgcolor="#FFFFFF">收 货 人：</td>
                            <td align="left" bgcolor="#FFFFFF">
                                <input name="txt_recever" type="text" class="inputBg required" maxlength="20" value="" />
                                <span style="color:#FF0000"> *</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="100" align="right" bgcolor="#FFFFFF">所在地区： </td>
                            <td align="left" bgcolor="#FFFFFF">
                                <select name="ddlProvince" id="ddlProvince"></select>
                                <select name="ddlRegion" id="ddlRegion"></select>
                                <select name="ddlCounty" id="ddlCounty"></select>
                            </td>
                        </tr>
                        <tr>
                            <td width="100" align="right" bgcolor="#FFFFFF">邮政编码： </td>
                            <td align="left" bgcolor="#FFFFFF">
                                <input name="txt_zip" type="text" class="inputBg required zipCode" value="" />
                                <span style="color:#FF0000"> *</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="100" align="right" bgcolor="#FFFFFF">手机号码： </td>
                            <td align="left" bgcolor="#FFFFFF">
                                <input name="txt_tel" type="text" class="inputBg required digits" maxlength="11" value="" />
                                <span style="color:#FF0000"> *</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="100" align="right" bgcolor="#FFFFFF">固定电话：</td>
                            <td align="left" bgcolor="#FFFFFF">
                                <input name="txt_phone" type="text" class="inputBg" maxlength="50" value="" />
                            </td>
                        </tr>
                        <tr>
                            <td width="100" align="right" bgcolor="#FFFFFF">详细地址： </td>
                            <td align="left" bgcolor="#FFFFFF">
                                <input name="txt_addressMain" type="text" class="inputBg required" value="" style="width:80%" />
                                <span style="color:#FF0000"> *</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="100" align="right" bgcolor="#FFFFFF"> </td>
                            <td align="left" bgcolor="#FFFFFF">
                                <input name="submit" type="submit" value="新增地址" class="bnt_blue_1" style="border:none;" />
                            </td>
                        </tr>
                    </table>
                }
            </div>
        </div>
    </div>
</div>


<div class="blank"></div>
